package com.ysstech.valuation.controller;


import com.ysstech.common.annotation.YssLog;
import com.ysstech.common.annotation.YssPermissions;
import com.ysstech.common.controller.BaseController;
import com.ysstech.common.util.resultutil.RestResult;
import com.ysstech.common.util.resultutil.ResultGenerator;
import com.ysstech.valuation.entity.BondDealDetailed;
import com.ysstech.valuation.service.BondDealDetailedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 债券交易流水 前端控制器
 * </p>
 *
 * @author lishuangliang
 * @since 2022-04-19
 */
@Controller
@Slf4j
@Api(tags = "债券交易流水管理api")
@RequestMapping("/bondDealDetailed")
public class BondDealDetailedController extends BaseController {

    @Autowired
    private BondDealDetailedService bondDealDetailedService;

    @YssPermissions(value = {"valuation:business:bond"})
    @ApiOperation(value = "跳转债券交易流水管理页面")
    @YssLog(module = "债券交易流水管理", remark = "跳转债券交易流水管理页面")
    @RequestMapping(value = "/page")
    public String page() throws Exception {
        return "valuation/bonddealdetailed";
    }

    @YssPermissions(value = {"valuation:business:bond"})
    @ApiOperation(value = "获取债券交易流水页面初始值")
    @YssLog(module = "债券交易流水管理", remark = "获取债券交易流水页面初始值")
    @PostMapping(value = "/init")
    @ResponseBody
    public RestResult init() throws Exception {
        Map<String, Object> map = new HashMap<>();
        return ResultGenerator.getSuccessResult("获取页面初始化信息成功", map);
    }

    /**
     * 获取债券交易流水信息
     *
     * @return
     */
    @YssPermissions(value = {"valuation:business:bond"})
    @ApiOperation(value = "获取债券交易流水信息")
    @YssLog(module = "债券交易流水管理", remark = "获取债券交易流水信息")
    @PostMapping(value = "/listInfo")
    @ResponseBody
    public RestResult listInfo(BondDealDetailed bondDealDetailed, String page, String rows) throws Exception {
        return ResultGenerator.getSuccessResult("获取债券信息信息成功",
                bondDealDetailedService.queryAllBondDealDetailed(bondDealDetailed, this.getPage(page, rows)));
    }


}
